<?php
/**
 * 短信通用业务逻辑类
 * User: 苏近之
 * Date: 2019-03-23
 * Time: 17:39
 */

namespace app\common\service;

use app\common\enum\CacheKeys;
use app\common\helper\sms\JuHe;
use think\facade\Cache;
use think\facade\Log;

class SmsService
{

    /**
     * 发送短信验证码
     * @param string $phone 手机号
     * @param $rand
     * @param int|string $templateId 模版ID
     * @param int $expire
     * @return bool
     */
    public static function send($phone, $rand, $templateId)
    {
        $result = JuHe::sendWithTemplate($phone, $templateId, $rand);
        if(!$result) {
            Log::error('Register Sms Send Failed:' . JuHe::getError());
            return false;
        }

        return true;
    }
}